/* Copyright (c) 2004-2024 Peigen.info. All rights reserved. */

package info.peigen.hotpot.component.gateway.dianlan.processor.business;

import info.peigen.hotpot.component.gateway.core.util.Cp56Time2aUtil;
import info.peigen.hotpot.component.gateway.dianlan.annotations.DianlanProtocolParse;
import info.peigen.hotpot.component.gateway.dianlan.processor.AbstractDianlanProcessor;
import info.peigen.hotpot.component.gateway.dianlan.protocol.Dianlan;
import info.peigen.hotpot.component.gateway.dianlan.protocol.active.DianlanSettingTimeChargeResponse;
import lombok.extern.slf4j.Slf4j;
import org.noear.solon.annotation.Component;
import org.smartboot.socket.MessageProcessor;
import org.smartboot.socket.StateMachineEnum;
import org.smartboot.socket.transport.AioSession;

/**
 * <b>(DianlanHeartProcessor)</b>
 *
 * @author czj
 * @version 1.0.0
 * @since 2022/11/17
 */
@Component("dianlanSettingTimeProcessor")
@Slf4j
public class DianlanSettingTimeProcessor<T> extends AbstractDianlanProcessor implements MessageProcessor<T> {

    @Override
    public void process(AioSession session, Object obj) {
        Dianlan                          dianlan     = (Dianlan) obj;
        DianlanSettingTimeChargeResponse settingTime = DianlanProtocolParse.deserialization(dianlan.getData(), DianlanSettingTimeChargeResponse.class);
        String                           decode      = Cp56Time2aUtil.decode(settingTime.getTime());
        log.info("电桩反馈时间：" + decode);
    }

    @Override
    public void stateEvent(AioSession session, StateMachineEnum stateMachineEnum, Throwable throwable) {
        MessageProcessor.super.stateEvent(session, stateMachineEnum, throwable);
    }
}